<?php
$startTime = time(true);
error_reporting(E_ALL);
ini_set('display_errors','On');
// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../lib'), 
    realpath(APPLICATION_PATH . '/../application/modules'),
    get_include_path(),
)));

require_once '../application/App.php';
require_once 'Core/Log.php';

/** Zend_Application */
require_once 'Zend/Application.php';
require_once "Zend/Loader/Autoloader.php";
require_once "Zend/Application/Module/Autoloader.php";
require_once "Zend/Loader/PluginLoader.php";
require_once "Zend/Loader.php";
require_once "Zend/Application/Resource/Frontcontroller.php";
require_once "Zend/Application/Bootstrap/ResourceBootstrapper.php";
require_once "Zend/Application/Bootstrap/Bootstrapper.php";
require_once "Zend/Application/Bootstrap/BootstrapAbstract.php";
require_once "Zend/Application/Bootstrap/Bootstrap.php";
require_once '../application/Bootstrap.php';
require_once "Zend/Controller/Front.php";
require_once "Zend/Registry.php";
require_once "Zend/Cache/Manager.php";
require_once "Zend/Application/Resource/Frontcontroller.php";
require_once "Zend/Controller/Dispatcher/Standard.php";
require_once "Zend/Application/Resource/Cachemanager.php";
require_once "Zend/Controller/Plugin/Broker.php";

Zend_Loader_Autoloader::getInstance();

$cache = App::getCache();
if (!($application = $cache->load("applicationInstance")))
{
	// Create application, bootstrap, and run
	$application = new Zend_Application(
	    APPLICATION_ENV,
	    App::getConfig(false, true)
	);
	$cache->save($application, "applicationInstance");
}

$application->bootstrap()->run();

if (APPLICATION_ENV == 'development')
echo microtime(true) - $startTime;